package Linked_New;

import java.io.*;
import java.util.Scanner;

public class LinkedTest_WuYuChu {
    public static void main(String[] args) throws IOException {
        int i,num;
        File file = new File("C:\\java", "data.txt");
        if (!file.exists()) {
            file.createNewFile();
        }
        Reader reader = new FileReader(file);
        BufferedReader bufferedReader = new BufferedReader(reader);
        String content = bufferedReader.readLine();

        String[] ss1 = content.split(" ");
        Linked[] list1 = new Linked[2];
        for(i=0;i<ss1.length;i++)
        {
            num=Integer.parseInt(ss1[i]);
            list1[i] = new Linked(num);
        }

        int nWuYuChu = 0,j=0;
        Scanner scan = new Scanner(System.in);
        System.out.println("please input your number and today's time");
        String s = scan.nextLine();
        String[] ss = s.split(" ");
        Linked[] list = new Linked[20];
        for(i=0;i<ss.length;i++)
        {
            num=Integer.parseInt(ss[i]);
            list[i] = new Linked(num);
            nWuYuChu++;
        }
        Linked head = list[0];
        for(i=0;i<nWuYuChu;i++)
        {
            list[j].setNext(list[++j]);
        }
        System.out.println("\n"+"you own :"+nWuYuChu+" elements");
                System.out.println(head.print(head));
        int a=5;
        System.out.println("insert elements 1:");
        head.insert(head,a-1,list1[0]);
        nWuYuChu++;
        System.out.println(head.print(head));

        System.out.println("insert elements 2:");
        head.insert(head,0,list1[1]);
        head = list1[1];
        nWuYuChu++;
        System.out.println(head.print(head));

        System.out.println("delete elements 1:");
        head.delete(head,5);
        System.out.println(head.print(head));
        nWuYuChu--;
        System.out.println("you own \"+nMaru+\" elements:"+nWuYuChu);

        System.out.println("20202321maopaopaixu,small to big");
        head.sort(head,nWuYuChu);
        System.out.println(head.print(head));

    }
}


